package com.slipper.qmt.constants;

import java.util.HashMap;
import java.util.Map;

public class Constants {
    public static class AccountType {
        public static final int FUTURE = 1; // 期货账号
        public static final int SECURITY = 2; // 证券账号
        public static final int CREDIT = 3; // 信用账号
        public static final int HUGANGTONG = 7; // 沪港通账号
        public static final int SHENGANGTONG = 11; // 深港通账号
    }

    public static class AccountStatus {
        public static final int INVALID = -1; // 无效
        public static final int OK = 0; // 正常
        public static final int WAITING_LOGIN = 1; // 连接中
        public static final int LOGINING = 2; // 登陆中
        public static final int FAIL = 3; // 失败
        public static final int INITING = 4; // 初始化中
        public static final int CORRECTING = 5; // 数据刷新校正中
        public static final int CLOSED = 6; // 收盘后
        public static final int ASSIS_FAIL = 7; // 穿透副链接断开
        public static final int DISABLEBYSYS = 8; // 系统停用（总线使用-密码错误超限）
        public static final int DISABLEBYUSER = 9; // 用户停用（总线使用）
    }

    public static class OrderType {
        public static final int TYPE_1101 = 1101; // 单股、单账号、普通、股/手方式下单
        public static final int TYPE_1102 = 1102; // 单股、单账号、普通、金额（元）方式下单（只支持股票）
        public static final int TYPE_1113 = 1113; // 单股、单账号、总资产、比例 [0 ~ 1] 方式下单
        public static final int TYPE_1123 = 1123; // 单股、单账号、可用、比例[0 ~ 1]方式下单
        public static final int TYPE_1201 = 1201; // 单股、账号组（无权重）、普通、股/手方式下单
        public static final int TYPE_1202 = 1202; // 单股、账号组（无权重）、普通、金额（元）方式下单（只支持股票）
        public static final int TYPE_1213 = 1213; // 单股、账号组（无权重）、总资产、比例 [0 ~ 1] 方式下单
        public static final int TYPE_1223 = 1223; // 单股、账号组（无权重）、可用、比例 [0 ~ 1] 方式下单
        public static final int TYPE_2101 = 2101; // 组合、单账号、普通、按组合股票数量（篮子中股票设定的数量）方式下单 > 对应 volume 的单位为篮子的份
        public static final int TYPE_2102 = 2102; // 组合、单账号、普通、按组合股票权重（篮子中股票设定的权重）方式下单 > 对应 volume 的单位为元
        public static final int TYPE_2103 = 2103; // 组合、单账号、普通、按账号可用方式下单 > （底层篮子股票怎么分配？答; // 按可用资金比例后按篮子中股票权重分配，如用户没填权重则按相等权重分配）只对股票篮子支持
        public static final int TYPE_2201 = 2201; // 组合、账号组（无权重）、普通、按组合股票数量方式下单
        public static final int TYPE_2202 = 2202; // 组合、账号组（无权重）、普通、按组合股票权重方式下单
        public static final int TYPE_2203 = 2203; // 组合、账号组（无权重）、普通、按账号可用方式下单只对股票篮子支持
    }

    public static class OrderStatus {
        // 委托状态已经在 ENTRUST_STATUS_CANCELED 或以上，但是成交数额还不够，等成交回报来
        public static final int ENTRUST_STATUS_WAIT_END = 0;
        public static final int ENTRUST_STATUS_UNREPORTED = 48; // 未报
        public static final int ENTRUST_STATUS_WAIT_REPORTING = 49; // 待报
        public static final int ENTRUST_STATUS_REPORTED = 50; // 已报
        public static final int ENTRUST_STATUS_REPORTED_CANCEL = 51; // 已报待撤
        public static final int ENTRUST_STATUS_PARTSUCC_CANCEL = 52; // 部成待撤
        public static final int ENTRUST_STATUS_PART_CANCEL = 53; // 部撤
        public static final int ENTRUST_STATUS_CANCELED = 54; // 已撤
        public static final int ENTRUST_STATUS_PART_SUCC = 55; // 部成
        public static final int ENTRUST_STATUS_SUCCEEDED = 56; // 已成
        public static final int ENTRUST_STATUS_JUNK = 57; // 废单
        public static final int ENTRUST_STATUS_DETERMINED = 86; // 已确认
        public static final int ENTRUST_STATUS_UNKNOWN = 255; // 未知

        public static final Map<Integer, String> map = new HashMap<Integer, String>(){{
            put(ENTRUST_STATUS_WAIT_END, "未知");
            put(ENTRUST_STATUS_UNREPORTED, "未报");
            put(ENTRUST_STATUS_WAIT_REPORTING, "待报");
            put(ENTRUST_STATUS_REPORTED, "已报");
            put(ENTRUST_STATUS_REPORTED_CANCEL, "已报待撤");
            put(ENTRUST_STATUS_PARTSUCC_CANCEL, "部成待撤");
            put(ENTRUST_STATUS_PART_CANCEL, "部撤");
            put(ENTRUST_STATUS_CANCELED, "已撤");
            put(ENTRUST_STATUS_PART_SUCC, "部成");
            put(ENTRUST_STATUS_SUCCEEDED, "已成");
            put(ENTRUST_STATUS_JUNK, "废单");
            put(ENTRUST_STATUS_UNKNOWN, "未知");
        }};

        public static String getValue(int key) {
            return map.get(key);
        }
    }

    public static class PriceType {
        public static final int LATEST_PRICE = 5; // # 最新价
        public static final int FIX_PRICE = 11; // # 指定价/限价
        public static final int MARKET_BEST = 18; // # 市价最优价[郑商所][期货]
        public static final int MARKET_CANCEL = 19; // # 市价即成剩撤[大商所][期货]
        public static final int MARKET_CANCEL_ALL = 20; // # 市价全额成交或撤[大商所][期货]
        public static final int MARKET_CANCEL_1 = 21; // # 市价最优一档即成剩撤[中金所][期货]
        public static final int MARKET_CANCEL_5 = 22; // # 市价最优五档即成剩撤[中金所][期货]
        public static final int MARKET_CONVERT_1 = 23; // # 市价最优一档即成剩转[中金所][期货]
        public static final int MARKET_CONVERT_5 = 24; // # 市价最优五档即成剩转[中金所][期货]
        public static final int MARKET_SH_CONVERT_5_CANCEL = 42; // # 最优五档即时成交剩余撤销[上交所][股票]
        public static final int MARKET_SH_CONVERT_5_LIMIT = 43; // # 最优五档即时成交剩转限价[上交所][股票]
        public static final int MARKET_PEER_PRICE_FIRST = 44; // # 对手方最优价格委托[上交所[股票]][深交所[股票][期权]]
        public static final int MARKET_MINE_PRICE_FIRST = 45; // # 本方最优价格委托[上交所[股票]][深交所[股票][期权]]
        public static final int MARKET_SZ_INSTBUSI_RESTCANCEL = 46; // # 即时成交剩余撤销委托[深交所][股票][期权]
        public static final int MARKET_SZ_CONVERT_5_CANCEL = 47; // # 最优五档即时成交剩余撤销[深交所][股票][期权]
        public static final int MARKET_SZ_FULL_OR_CANCEL = 48; // # 全额成交或撤销委托[深交所][股票][期权]
    }
}
